﻿namespace Sidvall.WorkItemManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class MonitoredWorkItem : global::Sidvall.WorkItemManager.UI.Entities.Core.BusinessBase, global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem
    {
        #region Business Members

        #region IsEnabled

        private bool _IsEnabled = false;
        partial void OnBeforeIsEnabledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsEnabled);
                OnBeforeIsEnabledPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                OnBeforeIsEnabledPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("IsEnabled", eventData.Value, true, true, true);
                    OnAfterIsEnabledPropertyChanged();
                }
            }
        }

        #endregion
        #region MaxExecutionTime

        private System.Nullable<System.TimeSpan> _MaxExecutionTime = null;
        partial void OnBeforeMaxExecutionTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeMaxExecutionTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterMaxExecutionTimePropertyChanged();
        public System.Nullable<System.TimeSpan> MaxExecutionTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_MaxExecutionTime);
                OnBeforeMaxExecutionTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _MaxExecutionTime);
                OnBeforeMaxExecutionTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxExecutionTime", eventData.Value, true, true, true);
                    OnAfterMaxExecutionTimePropertyChanged();
                }
            }
        }

        #endregion
        #region MaxExecutionTimeAlarmTimeout

        private System.Nullable<System.TimeSpan> _MaxExecutionTimeAlarmTimeout = null;
        partial void OnBeforeMaxExecutionTimeAlarmTimeoutPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeMaxExecutionTimeAlarmTimeoutPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterMaxExecutionTimeAlarmTimeoutPropertyChanged();
        public System.Nullable<System.TimeSpan> MaxExecutionTimeAlarmTimeout
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_MaxExecutionTimeAlarmTimeout);
                OnBeforeMaxExecutionTimeAlarmTimeoutPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _MaxExecutionTimeAlarmTimeout);
                OnBeforeMaxExecutionTimeAlarmTimeoutPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxExecutionTimeAlarmTimeout", eventData.Value, true, true, true);
                    OnAfterMaxExecutionTimeAlarmTimeoutPropertyChanged();
                }
            }
        }

        #endregion
        #region MaxFailedExecutionAlarmTimeout

        private System.Nullable<System.TimeSpan> _MaxFailedExecutionAlarmTimeout = null;
        partial void OnBeforeMaxFailedExecutionAlarmTimeoutPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeMaxFailedExecutionAlarmTimeoutPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterMaxFailedExecutionAlarmTimeoutPropertyChanged();
        public System.Nullable<System.TimeSpan> MaxFailedExecutionAlarmTimeout
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_MaxFailedExecutionAlarmTimeout);
                OnBeforeMaxFailedExecutionAlarmTimeoutPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _MaxFailedExecutionAlarmTimeout);
                OnBeforeMaxFailedExecutionAlarmTimeoutPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxFailedExecutionAlarmTimeout", eventData.Value, true, true, true);
                    OnAfterMaxFailedExecutionAlarmTimeoutPropertyChanged();
                }
            }
        }

        #endregion
        #region MaxFailedExecutionCount

        private System.Nullable<int> _MaxFailedExecutionCount = null;
        partial void OnBeforeMaxFailedExecutionCountPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData);
        partial void OnBeforeMaxFailedExecutionCountPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterMaxFailedExecutionCountPropertyChanged();
        public System.Nullable<int> MaxFailedExecutionCount
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<int>>(_MaxFailedExecutionCount);
                OnBeforeMaxFailedExecutionCountPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _MaxFailedExecutionCount);
                OnBeforeMaxFailedExecutionCountPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxFailedExecutionCount", eventData.Value, true, true, true);
                    OnAfterMaxFailedExecutionCountPropertyChanged();
                }
            }
        }

        #endregion
        #region MaxIdleTime

        private System.Nullable<System.TimeSpan> _MaxIdleTime = null;
        partial void OnBeforeMaxIdleTimePropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeMaxIdleTimePropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterMaxIdleTimePropertyChanged();
        public System.Nullable<System.TimeSpan> MaxIdleTime
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_MaxIdleTime);
                OnBeforeMaxIdleTimePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _MaxIdleTime);
                OnBeforeMaxIdleTimePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxIdleTime", eventData.Value, true, true, true);
                    OnAfterMaxIdleTimePropertyChanged();
                }
            }
        }

        #endregion
        #region MaxIdleTimeAlarmTimeout

        private System.Nullable<System.TimeSpan> _MaxIdleTimeAlarmTimeout = null;
        partial void OnBeforeMaxIdleTimeAlarmTimeoutPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeMaxIdleTimeAlarmTimeoutPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterMaxIdleTimeAlarmTimeoutPropertyChanged();
        public System.Nullable<System.TimeSpan> MaxIdleTimeAlarmTimeout
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_MaxIdleTimeAlarmTimeout);
                OnBeforeMaxIdleTimeAlarmTimeoutPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _MaxIdleTimeAlarmTimeout);
                OnBeforeMaxIdleTimeAlarmTimeoutPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MaxIdleTimeAlarmTimeout", eventData.Value, true, true, true);
                    OnAfterMaxIdleTimeAlarmTimeoutPropertyChanged();
                }
            }
        }

        #endregion
        #region MonitorContextId

        private int _MonitorContextId = 0;
        partial void OnBeforeMonitorContextIdPropertyGet(Sidvall.Business.PropertyEventData<int> eventData);
        partial void OnBeforeMonitorContextIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterMonitorContextIdPropertyChanged();
        public int MonitorContextId
        {
            get
            {
                Sidvall.Business.PropertyEventData<int> eventData = new Sidvall.Business.PropertyEventData<int>(_MonitorContextId);
                OnBeforeMonitorContextIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _MonitorContextId);
                OnBeforeMonitorContextIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MonitorContextId", eventData.Value, true, true, true);
                    OnAfterMonitorContextIdPropertyChanged();
                }
            }
        }

        #endregion
        #region MonitoredWorkItemId

        private System.Nullable<long> _MonitoredWorkItemId = null;
        partial void OnBeforeMonitoredWorkItemIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeMonitoredWorkItemIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterMonitoredWorkItemIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<long> MonitoredWorkItemId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_MonitoredWorkItemId);
                OnBeforeMonitoredWorkItemIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _MonitoredWorkItemId);
                OnBeforeMonitoredWorkItemIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MonitoredWorkItemId", eventData.Value, true, true, true);
                    OnAfterMonitoredWorkItemIdPropertyChanged();
                }
            }
        }

        #endregion
        #region SensorAlarmTimeout

        private System.Nullable<System.TimeSpan> _SensorAlarmTimeout = null;
        partial void OnBeforeSensorAlarmTimeoutPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnBeforeSensorAlarmTimeoutPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData);
        partial void OnAfterSensorAlarmTimeoutPropertyChanged();
        public System.Nullable<System.TimeSpan> SensorAlarmTimeout
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<System.TimeSpan>>(_SensorAlarmTimeout);
                OnBeforeSensorAlarmTimeoutPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<System.TimeSpan>>(value, _SensorAlarmTimeout);
                OnBeforeSensorAlarmTimeoutPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SensorAlarmTimeout", eventData.Value, true, true, true);
                    OnAfterSensorAlarmTimeoutPropertyChanged();
                }
            }
        }

        #endregion
        #region SensorComparisonOperator

        private global::Sidvall.Data.ComparisonOperator _SensorComparisonOperator = global::Sidvall.Data.ComparisonOperator.Equal;
        partial void OnBeforeSensorComparisonOperatorPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnBeforeSensorComparisonOperatorPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnAfterSensorComparisonOperatorPropertyChanged();
        public global::Sidvall.Data.ComparisonOperator SensorComparisonOperator
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator>(_SensorComparisonOperator);
                OnBeforeSensorComparisonOperatorPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator>(value, _SensorComparisonOperator);
                OnBeforeSensorComparisonOperatorPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SensorComparisonOperator", eventData.Value, true, true, true);
                    OnAfterSensorComparisonOperatorPropertyChanged();
                }
            }
        }

        #endregion
        #region SensorName

        private string _SensorName = string.Empty;
        partial void OnBeforeSensorNamePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeSensorNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSensorNamePropertyChanged();
        public string SensorName
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_SensorName);
                OnBeforeSensorNamePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SensorName);
                OnBeforeSensorNamePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SensorName", eventData.Value, true, true, true);
                    OnAfterSensorNamePropertyChanged();
                }
            }
        }

        #endregion
        #region SensorValue

        private string _SensorValue = string.Empty;
        partial void OnBeforeSensorValuePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeSensorValuePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSensorValuePropertyChanged();
        public string SensorValue
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_SensorValue);
                OnBeforeSensorValuePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SensorValue);
                OnBeforeSensorValuePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SensorValue", eventData.Value, true, true, true);
                    OnAfterSensorValuePropertyChanged();
                }
            }
        }

        #endregion
        #region WorkItemId

        private System.Nullable<long> _WorkItemId = null;
        partial void OnBeforeWorkItemIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeWorkItemIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterWorkItemIdPropertyChanged();
        public System.Nullable<long> WorkItemId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_WorkItemId);
                OnBeforeWorkItemIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _WorkItemId);
                OnBeforeWorkItemIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("WorkItemId", eventData.Value, true, true, true);
                    OnAfterWorkItemIdPropertyChanged();
                }
            }
        }

        #endregion
        #region MonitorContext

        private MonitorContext _MonitorContext;
        partial void OnBeforeMonitorContextPropertyChanged(Sidvall.Business.PropertyChangeEventData<MonitorContext> eventData);
        partial void OnAfterMonitorContextPropertyChanged();
        public MonitorContext MonitorContext
        {
            get
            {
                return _MonitorContext;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<MonitorContext> eventData = new Sidvall.Business.PropertyChangeEventData<MonitorContext>(value, _MonitorContext);
                OnBeforeMonitorContextPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("MonitorContext", eventData.Value, true, true, false);
                    OnAfterMonitorContextPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowIsValid

        public override bool DataRowIsValid(Sidvall.Data.BusinessRuleFilter filter)
        {
            return global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.DataRowIsValid(this, filter);
        }

        #endregion
        #region DataRowStateIsDirty

        public override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public MonitoredWorkItem Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public MonitoredWorkItem Copy()
        {
            return Copy(null);
        }
        public MonitoredWorkItem Copy(Sidvall.Data.CopySettings copySettings)
        {
            if (copySettings == null)
                copySettings = new Sidvall.Data.CopySettings();
            if (!Sidvall.Data.DataRowContextManager.IsValid(this, copySettings.RowFilter))
                return null;
            var item = new MonitoredWorkItem();
            Import(item, this, copySettings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem item)
        {
            Import(item, null);
        }
        public void Import(global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem item, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, item, copySettings);
        }
        partial void OnAfterImport(MonitoredWorkItem destination, global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem source, Sidvall.Data.CopySettings copySettings);
        private void Import(MonitoredWorkItem destination, global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(MonitoredWorkItem destination, MonitoredWorkItem source, Sidvall.Data.CopySettings copySettings);
        private void Import(MonitoredWorkItem destination, MonitoredWorkItem source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.ValidateAsync(this, context);
            await ValidateAsync(context);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync();
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.UI.SystemContextConfig.Current.EntityFacade.MonitoredWorkItemManager.Initialize(this, settings);
        }

        #endregion
        
        #region IMonitoredWorkItem Members

        bool global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxExecutionTime
        {
            get
            {
                return this._MaxExecutionTime;
            }
            set
            {
                this._MaxExecutionTime = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxExecutionTimeAlarmTimeout
        {
            get
            {
                return this._MaxExecutionTimeAlarmTimeout;
            }
            set
            {
                this._MaxExecutionTimeAlarmTimeout = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxFailedExecutionAlarmTimeout
        {
            get
            {
                return this._MaxFailedExecutionAlarmTimeout;
            }
            set
            {
                this._MaxFailedExecutionAlarmTimeout = value;
            }
        }
        System.Nullable<int> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxFailedExecutionCount
        {
            get
            {
                return this._MaxFailedExecutionCount;
            }
            set
            {
                this._MaxFailedExecutionCount = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxIdleTime
        {
            get
            {
                return this._MaxIdleTime;
            }
            set
            {
                this._MaxIdleTime = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MaxIdleTimeAlarmTimeout
        {
            get
            {
                return this._MaxIdleTimeAlarmTimeout;
            }
            set
            {
                this._MaxIdleTimeAlarmTimeout = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MonitorContextId
        {
            get
            {
                return this._MonitorContextId;
            }
            set
            {
                this._MonitorContextId = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MonitoredWorkItemId
        {
            get
            {
                return this._MonitoredWorkItemId;
            }
            set
            {
                this._MonitoredWorkItemId = value;
            }
        }
        System.Nullable<System.TimeSpan> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.SensorAlarmTimeout
        {
            get
            {
                return this._SensorAlarmTimeout;
            }
            set
            {
                this._SensorAlarmTimeout = value;
            }
        }
        global::Sidvall.Data.ComparisonOperator global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.SensorComparisonOperator
        {
            get
            {
                return this._SensorComparisonOperator;
            }
            set
            {
                this._SensorComparisonOperator = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.SensorName
        {
            get
            {
                return this._SensorName;
            }
            set
            {
                this._SensorName = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.SensorValue
        {
            get
            {
                return this._SensorValue;
            }
            set
            {
                this._SensorValue = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.WorkItemId
        {
            get
            {
                return this._WorkItemId;
            }
            set
            {
                this._WorkItemId = value;
            }
        }
        global::Sidvall.WorkItemManager.Data.IMonitorContext global::Sidvall.WorkItemManager.Data.IMonitoredWorkItem.MonitorContext
        {
            get
            {
                return this._MonitorContext;
            }
            set
            {
                UpdateChildProperty(this._MonitorContext, value);
                this._MonitorContext = value as MonitorContext;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public MonitoredWorkItem()
        {
        }

        public MonitoredWorkItem(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}